﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using DALayer;

namespace BALayer
{
    public class DBCTHoatDong
    {
        DAL db=null;
        public DBCTHoatDong()
        {
            db = new DAL();
        }
        public DataSet LayCTHoatDong()
        {
            return db.ExecuteQueryDataSet("select * from CTHoatDong", CommandType.Text, null);
        }
        public bool ThemCTHoatDong(ref string err, string MaHD, string TenHD)
        {
            return db.MyExecuteNonQuery("ThemCTHoatDong",
                CommandType.StoredProcedure, ref err,
                new SqlParameter("@MaHD", MaHD),
                new SqlParameter("@TenHD", TenHD));
        }
        public bool SuaCTHoatDong(ref string err, string MaHD, string TenHD)
        {
            return db.MyExecuteNonQuery("SuaCTHoatDong",
                CommandType.StoredProcedure, ref err,
                new SqlParameter("@MaHD", MaHD),
                new SqlParameter("@TenHD", TenHD));
        }
        public bool XoaCTHoatDong(ref string err, string MaHD)
        {
            return db.MyExecuteNonQuery("XoaCTHoatDong",
                CommandType.StoredProcedure, ref err,
                new SqlParameter("@MaHD", MaHD));
        }
        public DataSet TimKiemHoatDongTheoTen(string text)
        {
            return db.ExecuteQueryDataSet("select * " +
                " from CTHoatDong" +
                " where TenHD like N'%" + text + "%'", CommandType.Text, null);
        }
    }
}
